<?php
/**
 * <b>RUBIK IT Solution & Development ltd.</b>
 *
 * PROJECT		: Rubik Ultimate Framework
 * @version 	: 1.1
 * COPYRIGHT    : 2008
 * ------------------------------------------------------
 *
 * Created on	:  Jul 22, 2008
 *
 */

// no direct access
defined ( '_FW_EXEC' ) or die ( 'Restricted access' );
RCoreImporter::cls( "mvc.AbstractController" );
class HomeFrontController extends AbstractController {
	function display() {
		
		$viewall = SysLanguage::_('VIEWALL');
		$lang = $_REQUEST['lang'];
		SysResponse::prependPageTitle("Home");
		$root = SYS_ROOT_URL;
		//-------------load tin tuc---------------------------
		$sql = "SELECT * FROM event ORDER BY id DESC";
		$result = SysDatabase::loadObject($sql);
		$content = "";
		if($_REQUEST['lang'] == 'fr'){
			$content = $result->details_fr;
			$title = $result->title_fr;
			$btnEvent = 'Participer';
		} else if($_REQUEST['lang'] == 'en'){
			$content = $result->details_en;
			$title = $result->title_en;
			$btnEvent = 'Join it';

		}

		//-----------Load event---------------
		$sql1 = "SELECT * FROM event ORDER BY id DESC  LIMIT 3";
		$result_event = SysDatabase::loadObjectList($sql1);
		$event_item = "";
		foreach ($result_event as $row){
			$id = $row->id;
			$start = $row->start_date;
			$end = $row->end_date;
			$date  = date("d-m-Y");
			if (strtotime($date) > strtotime($start) && strtotime($date) < strtotime($end) ){
				if($_REQUEST['lang'] == 'fr'){
					$btnEvent = 'Participer';
					
				} else if($_REQUEST['lang'] == 'en'){
					$btnEvent = 'Join it';
					
				}
			}else {
				$btnEvent = "";
			}
			if($_REQUEST['lang'] == 'fr'){
				$title1 = $row->title_fr;
			} else if($_REQUEST['lang'] == 'en'){
				$title1 = $row->title_en;
			}
			$thumb = $row->thumbs;
			eval('$event_item .= "'.SysApplication::loadTemplate('front/event_item').'";');
		}

		$news = SysLanguage::_("NEWS");
		$newsDesc  = SysLanguage::_("NEWSDESC");

		eval('echo "'. SysApplication::loadTemplate('front/home').'";');

	}
}

?>